home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / bin / sos-CC < prev    next >
Text File  |  1992-02-13  |  4KB  |  123 lines

  1. #!/bin/sh
  2. # --------------------------------------------------------------------------
  3. # Copyright 1992 by Forschungszentrum Informatik (FZI)
  4. #
  5. # You can use and distribute this software under the terms of the licence
  6. # you should have received along with this program.
  7. # If not or if you want additional information, write to
  8. # Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  9. # D-7500 Karlsruhe 1, Germany.
  10. # --------------------------------------------------------------------------
  11. # 'sos-CC - 03/09/91 - Dietmar Theobald'
  12. #
  13. # sos-CC <command> [-o <object_file>] [-schema <schema>] [-no_scp] [-keep_scp]
  14. #           <args>...
  15. #
  16. # 'sos-CC' performs C++ compilations of SOS method implementations and schema
  17. # interface modules.
  18. # The actual compilation is done by executing the arguments with the
  19. # modifications listed below, i.e. the first argument is expected to be the
  20. # name of the C++ compiler.
  21. # After a successful compilation the generated object file is associated with
  22. # a schema using 'sos-sil'. To this end an object file must be named on the
  23. # command line by "-o <object_file>".
  24. #
  25. # Two kinds of source files may be compiled with 'sos-CC':
  26. #  - schema interface modules ("*_sos.c"), and
  27. #  - method implementations ("*.c", "*.cc", "*.C").
  28. #
  29. # The corresponding schema is given either explicitly using the '-schema'
  30. # option, or implicitly by looking for a single schema file in the directory
  31. # containing "*_sos.c", or "*.c" ("*.cc", "*.C") respectively.
  32. #
  33. # In case of compiling method implementations contained in '<p>.c' an
  34. # intermediary source file '<p>_scp.c' is maintained in the same directory as
  35. # '<p>.c'. This intermediary file is regenerated by the SOS preprocessor
  36. # 'sos-scp' each time '<p>.c' changes, or if '<p>_scp.c' does not exist.
  37. # The intermediary file is used as input for the compilation.
  38. # That preprocessing can be suppressed by the option '-no_scp'.
  39. # If the option '-keep_scp' is enabled, the file '<p>_scp.c' is kept after
  40. # the compilation, removed otherwise.
  41. #
  42.  
  43.    test="${SOSCONTAINER?}"
  44. tmp_scp='+'
  45.  
  46. while [ $# -gt 0 ] ; do
  47.    case "$1" in
  48.        -no_scp)  no_scp='+' ;;
  49.      -keep_scp) tmp_scp='' ;;
  50.  
  51.             -o) [ "$outfile" ] && {
  52.                    echo >&2 '*** sos-CC: multiple "-o" options'; exit 1
  53.                    }
  54.                 shift ; outfile="$1" ;;
  55.        -schema) [ "$schema"  ] && {
  56.                    echo >&2 '*** sos-CC: multiple "-schema" options'; exit 1
  57.                    }
  58.                   shift ; schema="$1" ;;
  59.        *_sos.c) [ "$infile"  ] && {
  60.                    echo >&2 '*** sos-CC: multiple source files'; exit 1
  61.                    }
  62.                   infile="$1" ;;
  63.          *.c |\
  64.      *.C |\
  65.          *.cc ) [ "$infile"  ] && {
  66.                    echo >&2 '*** sos-CC: multiple source files'; exit 1
  67.                    }
  68.                     infile="$1"
  69.           suffix="`expr match "$1" '.*\.\([^.]*\)'"
  70.                   call_scp='+' ;;
  71.              *) args="$args '$1'"    ;;
  72.    esac
  73.    shift
  74. done
  75. [ "$no_scp"  ] && { call_scp=''; tmp_scp='' ;}
  76. [ "$infile"  ] || { echo >&2 '*** sos-CC: source file missing'; exit 1 ;}
  77. [ "$outfile" ] || { echo >&2 '*** sos-CC: object file missing'; exit 1 ;}
  78.  
  79. in_dir=`dirname "$infile"`
  80. [ "$schema" ] || {
  81.    set $in_dir/*.sos ""
  82.       
  83.    if [ $# -gt 2 ] ; then
  84.       echo >&2 "*** sos-CC: several SOS schema files in $in_dir"
  85.       exit 1
  86.    elif [ -f "$1" ] 2> /dev/null ; then
  87.       schema=`basename "$1" .sos`
  88.    else
  89.       echo >&2 "*** sos-CC: no SOS schema file in $in_dir"
  90.       exit 1
  91.    fi
  92.    }
  93.  
  94. [ "$call_scp" ] && {
  95.    im_file=`expr match "$infile" "\(.*\).$suffix"`_scp.c
  96.   
  97.    if [ "$tmp_scp" ] ; then
  98.       del_file="$im_file"
  99.    else
  100.       set `ls -L -t $infile $im_file 2> /dev/null` ""
  101.       [ "$1" = "$infile" ] || call_scp=''
  102.    fi
  103.    [ "$call_scp" ] && { echo "+ sos-scp $schema -o $im_file $infile"
  104.                sos-scp $schema -o $im_file $infile || exit 1
  105.                  }
  106.    infile="$im_file"
  107.    }
  108.  
  109. eval `echo "echo + $args -o $outfile $infile"`
  110. eval `echo "$args -o $outfile $infile"`
  111.  
  112. status=$?
  113. [ $status -eq 0 ] && {
  114.    echo "+ sos-sil $schema -a $outfile"
  115.    sos-sil $schema -a $outfile || { 
  116.       [ "$SOSC_BOOTING" ] || { rm -f $outfile $del_file; exit 1 ;}
  117.       echo "(error ignored during bootstrap)"
  118.       }
  119.    }
  120. rm -f $del_file
  121.  
  122. exit $status
  123.